﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ChuangDu_Spirit_QGB_Model.Log;
using System.Security.Cryptography;
using System.Text;
using ChuangDu_Spirit_QGB_BLL.ZWLBLL;
using ChuangDu_Spirit_QGB_BLLContainer;
using ChuangDu_Spirit_QGB_IBLL.ZWLIBLL;
using System.Web.Security;
using System.Data.SqlClient;
using System.Data;
namespace ChuangDu_Spirit_QGB.Areas.Sprintzwl.Controllers
{
    public class CommandController : Controller
    {
        private static SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=ChuangDu_Spirit_QGB_DB;Integrated Security=True");
        // GET: Sprintzwl/Command
        public object deng(User_Log l)
        {
            conn.Open();
            string sql = string.Format("select * from CRMLog where User_name='{0}' and User_pwd='{1}'", l.User_name, l.User_pwd);
            SqlCommand cmd = new SqlCommand(sql, conn);
            object o = cmd.ExecuteScalar();
            conn.Close();
            return o;
        }
        public bool de(User_Log u)
        {
            bool fag = false;
            object o = deng(u);
            if(o!=null)
            {
                fag = true;
            }
            return fag;
        }
        public object Log()
        {
            return View();
        }
        [HttpPost]
        public ActionResult Log(string nickname,string pwd)
        {
            User_Log m = new User_Log();
            m.User_name = nickname;
            m.User_pwd = pwd;
            bool ok = de(m);
            if(ok)
            {
                return Redirect("~/Sprintzbh/Pschance/Index");
            }
            else
            {
                return Redirect("登录失败");
            }
        }
        /// <summary>
        /// 登录提交
        /// </summary>
        /// <returns></returns>
        /// 
        
        /// <summary>
        /// 工作台
        /// </summary>
        /// <returns></returns>
        public ActionResult Control()
        {
            return View();
        }
        /// <summary>
        /// 销售目标视图
        /// </summary>
        /// <returns></returns>
        public ActionResult Sell()
        {
            return View();
        }
        /// <summary>
        /// 公海统计
        /// </summary>
        /// <returns></returns>
        public ActionResult StatisticsHigh()
        {
            return View();
        }
        /// <summary>
        /// 登录
        /// </summary>
        /// <returns></returns>
        public ActionResult LogIn()
        {
            return View();
        }
        public ActionResult ZhuanHuan()
        {
            return View();
        }
       public ActionResult za()
        {
            return View();
        }
    }
}